package com.huang.Controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RefreshScope
public class NacosConfigController {
    
    @Autowired
    private ConfigurableApplicationContext applicationContext;

    @Value("${config.appName}")
    private String nacos;

    @Value("${config.env}")
    private String dev;
    
    @GetMapping("/test_nacos")
    public String test01(){
        String property = applicationContext.getEnvironment().getProperty("config.appName");
        return property;
    }

    @GetMapping("/test_nacos02")
    public String test02(){
        return nacos;
    }

    @GetMapping("/test03_dev")
    public String test03(){
        return dev;
    }
    
}
